// 全局 router拦截

import router from '@/router/index'
import { getPageTitle } from './settings'

import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
NProgress.configure({ showSpinner: false }) // NProgress Configuration

router.beforeEach(async(to, from, next) => {
  // start progress bar
  NProgress.start()

  // set page title
  document.title = getPageTitle(to.meta.title)

  next();
  
  NProgress.done()

})

router.afterEach(() => {
  // finish progress bar
  NProgress.done()
})

